Skip to main content
Version: 16.8.2

word_search

Success

class Success(WordSearchSuccess)

WordSearch success code 1.

success_codes

success_codes = {
1: Success,
}

UnknownErrorCode

class UnknownErrorCode(WordSearchError)

Unknown error code.

Fail

class Fail(WordSearchError)

WordSearch error code 0.

DisallowedItemFound

class DisallowedItemFound(WordSearchError)

WordSearch error code -1024. Item disallowed by policy found in file.

RequiredItemNotFound

class RequiredItemNotFound(WordSearchError)

WordSearch error code -1025. Item required by policy not found in file.

IllegalActionRedact

class IllegalActionRedact(WordSearchError)

WordSearch error code -1026. Redact action specified but filetype doesn't support redaction.

IllegalActionRequire

class IllegalActionRequire(WordSearchError)

WordSearch error code -1027. Require action specified but filetype doesn't support redaction.

IllegalActionNoRequire

class IllegalActionNoRequire(WordSearchError)

WordSearch error code -1028. Require action not specified but filetype needs one.

FiletypeUnsupported

class FiletypeUnsupported(WordSearchError)

WordSearch error code -1029. Filetype supported by Editor but not by Word Search.

error_codes

error_codes = {
0: Fail,
-1024: DisallowedItemFound,
-1025: RequiredItemNotFound,
-1 ...

WordSearchError

class WordSearchError(Exception)

Base class for all WordSearch errors.

WordSearchSuccess

class WordSearchSuccess()

Base class for all WordSearch successes.

WordSearch

class WordSearch(Library)

A high level Python wrapper for Glasswall WordSearch.

__init__

def __init__(library_path: str)

version

def version()

Returns the Glasswall library version.

Returns:

  • version str - The Glasswall library version.

redact_file

@glasswall.utils.deprecated_alias(xml_config="content_management_policy")
def redact_file(input_file: Union[str, bytes, bytearray, io.BytesIO],
content_management_policy: Union[str, bytes, bytearray,
io.BytesIO],
output_file: Union[None, str] = None,
output_report: Union[None, str] = None,
homoglyphs: Union[None, str, bytes, bytearray,
io.BytesIO] = None,
raise_unsupported: bool = True)

Redacts text from input_file using the given content_management_policy and homoglyphs file, optionally writing the redacted file and report to the paths specified by output_file and output_report.

Arguments:

  • input_file Union[str, bytes, bytearray, io.BytesIO] - The input file path or bytes. content_management_policy (Union[str, bytes, bytearray, io.BytesIO)]): The content management policy to apply.
  • output_file Union[None, str], optional - Default None. If str, write output_file to that path.
  • output_report Union[None, str], optional - Default None. If str, write output_file to that path. homoglyphs (Union[None, str, bytes, bytearray, io.BytesIO)], optional): Default None. The homoglyphs json file path or bytes.
  • raise_unsupported bool, optional - Default True. Raise exceptions when Glasswall encounters an error. Fail silently if False.

Returns:

  • gw_return_object glasswall.GwReturnObj - An instance of class glasswall.GwReturnObj containing attributes: "status" (int), "output_file" (bytes), "output_report" (bytes)

redact_directory

@glasswall.utils.deprecated_alias(xml_config="content_management_policy")
def redact_directory(input_directory: str,
content_management_policy: Union[
str, bytes, bytearray, io.BytesIO,
glasswall.content_management.policies.policy.Policy],
output_directory: Optional[str] = None,
output_report_directory: Optional[str] = None,
homoglyphs: Union[None, str, bytes, bytearray,
io.BytesIO] = None,
raise_unsupported: bool = True)

Redacts all files in a directory and it's subdirectories using the given content_management_policy and homoglyphs file. The redacted files are written to output_directory maintaining the same directory structure as input_directory.

Arguments:

  • input_directory str - The input directory containing files to redact.
  • output_directory str - The output directory where the redacted files will be written.
  • output_report_directory Optional[str], optional - Default None. If str, the output directory where analysis reports for each redacted file will be written. content_management_policy (Union[str, bytes, bytearray, io.BytesIO)]): The content management policy to apply. homoglyphs (Union[None, str, bytes, bytearray, io.BytesIO)], optional): Default None. The homoglyphs file path, str, or bytes.
  • raise_unsupported bool, optional - Default True. Raise exceptions when Glasswall encounters an error. Fail silently if False.

Returns:

  • redacted_files_dict dict - A dictionary of file paths relative to input_directory, and glasswall.GwReturnObj with attributes: "status" (int), "output_file" (bytes), "output_report" (bytes)